package eu.somatik.somaftp.gui;
/*
 * FileListCellRenderer.java
 *
 * Created on December 2, 2006, 12:05 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import com.glub.secureftp.bean.RemoteFile;
import eu.somatik.somaftp.logic.FileInterface;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author francisdb
 */
public class FileListCellRenderer extends DefaultTableCellRenderer{
    
    private ImageIcon iconFile;
    private ImageIcon iconDir;
    private ImageIcon iconDirUp;
    private ImageIcon iconLink;
    
    
    /** Creates a new instance of FileListCellRenderer */
    public FileListCellRenderer() {
        super();
        
        iconFile = new ImageIcon(getClass().getResource("/eu/somatik/somaftp/icons/text-x-generic.png"));
        iconDir = new ImageIcon(getClass().getResource("/eu/somatik/somaftp/icons/folder-remote.png"));
        iconDirUp = new ImageIcon(getClass().getResource("/eu/somatik/somaftp/icons/folder-visiting.png"));
        iconLink = new ImageIcon(getClass().getResource("/eu/somatik/somaftp/icons/emblem-symbolic-link.png"));
                
    }


    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
        if(value instanceof FileInterface) {
            FileInterface file = (FileInterface) value;
            if("..".equals(file.getName())){
                this.setIcon(iconDirUp);
            }else if(file.isDirectory()){
                this.setIcon(iconDir);
            }else if(file.isLink()){
                this.setIcon(iconLink);
            }else{
                this.setIcon(iconFile);
            }
        }
        return this;
    }
    

    
}
